var inp1=document.querySelector("[name=username]");
inp1.onfocus=function(){
	this.style.color="#333";
	this.style.border="1px solid #909090";
	this.style.borderBottom="1px solid #ddd";
	this.style.zIndex="1";
}
inp1.onblur=function(){
	this.style.zIndex="0";
	if(this.value==""){
		this.style.border="1px solid red";
	}
	var reg=/^(\+86|0086)?\s*[1][3-9]\d{9}$/;
	if(reg.test(this.value)){
		this.style.color="#333";
		this.style.border="1px solid #909090";
		this.style.borderBottom="1px solid #ddd";
	}else{
		this.style.border="1px solid red";
		this.style.color="red";
	}
}
var inp2=document.querySelector("[name=pwd]");
inp2.onfocus=function(){
	this.style.color="#333";
	this.style.border="1px solid #909090";
	this.style.borderBottom="1px solid #ddd";
}
inp2.onblur=function(){
	if(this.value==""){
		this.style.border="1px solid red";
	}
	var reg=/^(?![0-9]+$)(?![a-zA-Z]+$)(?![!@#$%^&*()~?]+$)[a-zA-Z0-9!@#$%^&*()~?]{8,16}$/;
	if(reg.test(this.value)){
		this.style.color="#333";
		this.style.border="1px solid #909090";
		this.style.borderBottom="1px solid #ddd";
	}else{
		this.style.border="1px solid red";
		this.style.color="red";
	}
}

var jz=document.querySelector("[name=keep_on]");
var sub=document.querySelector("[class=sub]");
jz.checked = true;
var inps=document.getElementsByTagName("input");
var form=document.getElementsByTagName("form")[0];
if(localStorage.length>0){
	inp1.value=localStorage.name;
	inp2.value=localStorage.pass;
}
form.onsubmit=function(){
	if(jz.checked){
//		localStorage.clear();
		localStorage.name=inp1.value;
		localStorage.pass=inp2.value;
	}
	for(var i=0;i<inps.length-4;i++){
		inps[i].onblur();
		if(inps[i].style.color=="red"){
			return false;
		}
	}
}
console.log(localStorage);
inps[5].onclick=()=>{
	location="setup.html"
}
var img=document.getElementsByTagName("img")[0];
img.onclick=function(){
	location="singapore.html";
}
